Matrix-Vector Product

Introduction

The matrix–vector product is one of the most important ideas in linear algebra.
It acts as a bridge between simple vector operations and the powerful concept of linear transformations.
If you already know how to add vectors and scale them, you’re ready for this next step.

What Is a Matrix?

A matrix is a rectangular grid of numbers. For our purposes, think of it as a compact way to store several vectors at once.

Matrices allow us to apply the same operation to many vectors efficiently.

Defining the Matrix–Vector Product

Suppose we have a matrix $$A = \begin{bmatrix} a & b \\ c & d \end{bmatrix}$$ and a vector $$x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix}.$$ The matrix–vector product $Ax$ is defined as:

In symbols: $$Ax = x_1 \begin{bmatrix} a \\ c \end{bmatrix} + x_2 \begin{bmatrix} b \\ d \end{bmatrix}.$$ This is just a linear combination of the columns of $A$.

Why This Matters

The matrix–vector product is not just a computation trick. It encodes a rule for transforming vectors.

All of these geometric actions can be expressed using matrices.

Key idea:

This is the essence of a linear transformation.

Geometric Interpretation

When you multiply a matrix by a vector:

Example:
If $$A = \begin{bmatrix} 2 & 0 \\ 0 & 3 \end{bmatrix},$$ then:

So $A$ scales space differently along each axis.

Computing Matrix–Vector Products

Here’s the standard computational rule for a $2 \times 2$ matrix: $$\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} ax_1 + bx_2 \\ cx_1 + dx_2 \end{bmatrix}.$$ For a $3 \times 3$ matrix, the idea is the same—each row forms a dot product with the vector.

Examples

Example 1

Compute $$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 5 \\ 1 \end{bmatrix}.$$

Result: $$\begin{bmatrix} 7 \\ 19 \end{bmatrix}.$$

Example 2

Interpret $$\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$$ geometrically.

This matrix rotates any vector by $90^\circ$ counterclockwise.

Calculator

Multiplying matrices and vectors

  • A vector can be multiplied by a matrix in the same way as any other data type:
[1, 2; 3, 4] * [5, 1] multiply([2, 1; 0, 3], [4, -2])

Exercises

  1. Compute $$\begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 4 \\ -2 \end{bmatrix}.$$

    Solution

    $$\begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix} \begin{bmatrix} 4 \\ -2 \end{bmatrix} = \begin{bmatrix} 2\cdot 4 + 1\cdot (-2) \\ 0\cdot 4 + 3\cdot (-2) \end{bmatrix} = \begin{bmatrix} 6 \\ -6 \end{bmatrix}.$$

  2. Write the matrix–vector product $Ax$ as a linear combination of the columns of $A$ for $$A = \begin{bmatrix} 1 & -1 \\ 2 & 3 \end{bmatrix}, \quad x = \begin{bmatrix} 3 \\ 5 \end{bmatrix}.$$

    Solution

    Linear combination form: $$Ax = 3\begin{bmatrix}1 \\ 2\end{bmatrix} + 5\begin{bmatrix}-1 \\ 3\end{bmatrix}.$$

  3. Compute $$\begin{bmatrix} 0 & 2 \\ -1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 3 \end{bmatrix}.$$

    Solution

    $$\begin{bmatrix} 0 & 2 \\ -1 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 3 \end{bmatrix} = \begin{bmatrix} 6 \\ 2 \end{bmatrix}.$$

  4. Describe in words what the matrix $$\begin{bmatrix} 3 & 0 \\ 0 & 1 \end{bmatrix}$$ does to vectors.

    Solution

    The matrix stretches vectors by a factor of $3$ in the $x$-direction and leaves the $y$-direction unchanged.

  5. True or false: The matrix–vector product always produces a vector in the same dimension as the number of rows of the matrix.

    Solution

    True.
    The output dimension is always equal to the number of rows of the matrix.

  6. Compute $$\begin{bmatrix} 1 & 2 & 0 \\ -1 & 0 & 3 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ -1 \end{bmatrix}.$$

    Solution

    $$\begin{bmatrix} 1 & 2 & 0 \\ -1 & 0 & 3 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ -1 \end{bmatrix} = \begin{bmatrix} 1\cdot 2 + 2\cdot 1 + 0\cdot (-1) \\ -1\cdot 2 + 0\cdot 1 + 3\cdot (-1) \end{bmatrix} = \begin{bmatrix} 4 \\ -5 \end{bmatrix}.$$

  7. Express the matrix–vector product as a dot-product computation for $$A = \begin{bmatrix} 4 & 1 \\ 2 & -2 \end{bmatrix}, \quad x = \begin{bmatrix} 1 \\ 6 \end{bmatrix}.$$

    Solution

    Dot-product form:

    • First entry: $4\cdot 1 + 1\cdot 6 = 10$
    • Second entry: $2\cdot 1 + (-2)\cdot 6 = -10$

    So $$Ax = \begin{bmatrix} 10 \\ -10 \end{bmatrix}.$$